package com.fbs.controller;

import com.aaa.entity.EMessage;
import com.aaa.vo.EMessageVo;
import com.aaa.vo.Result;
import com.fbs.service.EMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Api("emp/message")
@RestController
@RequestMapping("emp/message")
@EnableSwagger2
public class EMessageController {
    @Autowired
    private EMessageService eMessageService;
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "EMessageVo", name = "eMessageVo", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @RequestMapping("/findAll")
    public Result findAll(@RequestBody EMessageVo eMessageVo){
        System.out.println("eMessageVo.toString() = " + eMessageVo.toString());
        Result all = eMessageService.findAll(eMessageVo.getStartTime(), eMessageVo.getEndTime(), eMessageVo.getCurrentPage(), eMessageVo.getPageSize());
        return all;
    }
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "int", name = "id", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @RequestMapping("deleteById/{id}")
    public Result deleteById(@PathVariable Integer id){
        return eMessageService.deleteById(id);
    }
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "EMessage", name = "eMessage", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @RequestMapping("update")
    public Result update(@RequestBody EMessage eMessage){
        return eMessageService.update(eMessage);
    }
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "EMessage", name = "eMessage", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @RequestMapping("save")
    public Result save(@RequestBody EMessage eMessage){
        System.out.println("eMessage = " + eMessage);
        return eMessageService.save(eMessage);
    }
}
